<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>米尔豪斯酒店后台管理系统</title>
	<link rel="stylesheet" type="text/css" href="../../css/consult.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <link rel="stylesheet" type="text/css" href="../../css/page.css">
	<script type="text/javascript" language="javascript">
		function confirmAct() { 
		   if(confirm('确定要退出登陆吗?') == true) {
		   	　window.location.href="../../html/admin_login.html";
   			}
		}
        function consult_delete(id) {
            window.location.href = "consult_delete.php?id="+id;
        }
        function consult_editor(consult_id) {
            window.location.href = "consult_editor.php?consult_id="+consult_id;
        }
	</script>
</head>
<body>
	<div class="all">	
		<div class="all1">
			<h1>米尔豪斯酒店后台管理系统</h1>
		</div>

        <?php
        include '../menu.php';
        session_start();
        header("Content-type:text/html;charset=utf-8");
        include "../../../lib/DB.php";
        include "../../../lib/Pagination.php";
        $db = new DB();
        $page = isset($_GET['page']) ? $_GET['page'] : 1;
        $pageSize = isset($_GET['pageSize']) ? abs($_GET['pageSize']) : 10;
        $goods = $db->table('orders')->page($page,$pageSize)->order('id desc')->select();
        $count = "select count(*) as count from  orders";
        $goodsCount = $db->table('orders')->query($count)['0']['count'];
        $pagination = new Pagination($goodsCount,$pageSize);

        if(isset($_GET['act']) == 'del')
        {
            $db->table('orders')->where(['id' => $_GET['id']])->delete();
            echo "<script >alert('删除成功..');location.href='dingdan.php'</script>";
            die;
        }


        $num = 0;
        ?>

		<div class="all3" >
			<div class="guide">
				<p><img src="../../img/主页.png">&nbsp;&nbsp;当前位置 ： 后台管理 > 订单管理 </p>
			</div>
			<div class="data">
					<div class="add">
						<a href="../consult_add.php"><img src="../../img/添加.png">&nbsp;添加</a>
					</div>
					<div class="content">
						<table class="table table-hover table-responsive">
								<tr>
									<th>ID</th>
									<th>订单号</th>
									<th>下单时间</th>
									<th>下单金额</th>
									<th>用户名</th>
									<th>订单菜品</th>
									<th>操作</th>
								</tr>

                            <?php foreach ($goods as $k => $row):?>
                            <tr>
                                <td ><?php echo $num = $k+1;?></td>
                                <td ><?php echo $row['order_no']?></td>
                                <td ><?php echo $row['created_at']?></>
                                <td ><?php echo $row['total']?></td>
                                <td ><?php echo $row['user_name']?></td>
                                <td ><?php echo $row['goods_ids']?></td>
                                <td ><a href="?act=del&id=<?php echo $row['id'];?>"><button class="btn btn-info btn-xs">删除</button><a> <!--<button class="btn btn-danger btn-xs">编辑</button>--></td>
                            </tr>
                            <?php endforeach;?>
						</table>
					</div>
                <?php echo $pagination->links();?>

			</div>
		</div>
		<div class="all4">
			<h3>米尔豪斯酒店</h3>
		</div>
	</div>
</body>
</html>